package model.action.basic_function_action;

import org.apache.log4j.Logger;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.ParentPackage;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.Results;

import common.base.BaseAction;

@Results({
	@Result(name = "ConsumerRegister", type = "tiles", location = "tiles.ConsumerRegister"),
	@Result(name = "BusinessRegister", type = "tiles", location = "tiles.BusinessRegister"),
	@Result(name = "RegisterTypeLoad", type = "tiles", location = "tiles.UserType"),
	@Result(name = "errorEx", type = "tiles", location = "tiles.error"),
	@Result(name = "success", type = "tiles", location = "tiles.welcome") })	
@ParentPackage("master_tiles")
public class RegisterTypeAction extends BaseAction {

	/**
	 * 
	 */
	protected static Logger log = Logger.getLogger(RegisterTypeAction.class);
	private static final long serialVersionUID = 1L;
	
	public String execute() {
		return SUCCESS;
	}

	public String display() {
		return NONE;
	}
	// ======================================================================================================
	// LOAD REGISTER TYPE FORM
	@Action("/master/register-type")
	public String UserType() {
		getCityList();
		getCityList2();
		loadParentDealCategory();
		return "RegisterTypeLoad";
	}
	
	// ======================================================================================================
	// LOAD  REGISTER CONSUMER FORM
	@Action("/master/Register_Consumer")
	public String ConsumerRegist() {
		try {
			getCityList();
			getCityList2();
			loadParentDealCategory();
			getDistrictList(Integer.parseInt(getCitySelected() == null ? "1"
					: getCitySelected()));
			createGenderList();
			return "ConsumerRegister";
		} catch (Exception e) {
			return "errorEx";
		}
	}

	// ======================================================================================================
	// LOAD REGISTER BUSINESS FORM
	@Action("/master/Register_Business")
	public String BusinessRegist() {
		try {
			getCityList();
			getCityList2();
			loadParentDealCategory();
			getDistrictList(Integer.parseInt(getCitySelected() == null ? "1"
					: getCitySelected()));
			createGenderList();
			return "BusinessRegister";
		} catch (Exception e) {
			return "errorEx";
		}
	}
}
